<extend name="Public/layout"/>
<block name="head">
    <link rel="stylesheet" href="__PUBLIC__css/notice.css">
        <style type="text/css">
        .footer{
            display: none;
        }
        </style>
</block>
<block name="main">
    <div class="switch" style="display: none;">
        <ul class="switch-wrapper">
            <if condition="$_GET[val] eq 2">
            <li onTouchStart="switchButton(this,1)" class="active" >
                <div <if condition='$notice_reads eq 1'>class="hasMsg"</if> >公告</div>
            </li>
            <else/>
            <li onTouchStart="switchButton(this,2)">
                <div <if condition='$unread'>class="hasMsg" </if>>站内信</div>
            </li>
            </if>
        </ul>
    </div>

    <div class="notice-wrapper" id="notice">
        <foreach name="news" item="v">

                <div id="news" class="notice <if condition='$v.is_read eq 0'> new </if>">

                    <a href="javascript:" onclick="to_notice(this,{$v.id})">
                        <h3 <if condition='$v.is_read eq 1'>  style="color: #999999;" </if> >{$v.title}</h3>
                        <div class="desc">
                            <p>尊敬的{$v.nickname}用户：{$v.content_short}</p>
                        </div>
                        <div class="notice-info">
                            <span class="notice-date">{$v.notice_date}</span>
                            <span class="notice-time">{$v.notice_time}</span>
                            <span class="more">查看详情></span>
                        </div>
                    </a>
                </div>
        </foreach>
    </div>
    <div class="notice-wrapper" id="notice_mes" style="display: none">
        <foreach name="mes" item="v">

                <div id="mes" class="notice <if condition='$v[is_read] eq 0'>new </if>">

                    <a href="javascript:" onclick="to_mes(this,{$v.id})">
                        <h3  <if condition='$v.is_read eq 1'>  style="color: #999999;" </if> >{$v.type_id}</h3>
                        <div class="desc">
                            <p>尊敬的{$v.nickname}用户：{$v.content}</p>
                        </div>
                        <div class="notice-info">
                            <span class="notice-date">{$v.notice_date}</span>
                            <span class="notice-time">{$v.notice_time}</span>
                            <span class="more">查看详情></span>
                        </div>
                    </a>
                </div>
        </foreach>
    </div>
</block>
<block name="js">
    <script>
        function switchButton(obj,val) {
//            $(obj).addClass('active').siblings().removeClass('active')
            if(val==2) {
                location.href="/Home/Person/notice/val/2"
                $('#notice').attr("style", "display:none;");
                $('#notice_mes').attr("style", "display:block;");
            } else if(val==1) {
                 location.href="/Home/Person/notice/val/1"
                $('#notice_mes').attr("style", "display:none;");
                $('#notice').attr("style", "display:block;");
            }
        }
        $(function(){
            var val = "{$_GET['val']}";
            j = parseInt(val)-1
            if (val) {
                $('.switch-wrapper').find('li').removeClass('active')
                $('.switch-wrapper').find('li').eq(j).addClass('active')
            }
            if(val==2) {

                $('#notice').attr("style", "display:none;");
                $('#notice_mes').attr("style", "display:block;");
            } else if(val==1) {
                $('#notice_mes').attr("style", "display:none;");
                $('#notice').attr("style", "display:block;");
            }

        })


        function to_notice(obj,id){
            location.href="/Home/Person/notice_details/news_id/"+id
            $(obj).parent('#news').removeClass('new')
        }


        function to_mes(obj,id){
            location.href="/Home/Person/notice_message/mes_id/"+id
            $(obj).parent('#mes').removeClass('new')
        }

    </script>
</block>
